using System;
using System.Data;
using System.IO;
using System.Threading;
using Firestarter.DB.Schema.Logic;
using Habanero.Base;
using Habanero.DB;

namespace Firestarter.DB.Schema.Test.Logic
{
    public class TestUtilsDB_Access : TestUtilsDB
    {
        public override DatabaseConfig CreateTestDatabaseConfig()
        {
            return new DatabaseConfig("Access", "", TestDatabaseName + ".mdb", "", "", null);
        }

        protected override DatabaseConfig CreateMasterDatabaseConfig()
        {
            throw new NotImplementedException();
        }

        public override CreateTableSqlBuilder CreateSqlBuilderCreateTable(string tableName) { return new CreateTableSqlBuilder_Access(tableName); }

        public override void CreateTestDatabase()
        {
            // just copy the file since Access is a file-based database.
            try
            {
                string databaseFileName = TestDatabaseName + ".mdb";
                if (File.Exists(databaseFileName)) File.Delete(databaseFileName);
                File.Copy("Schema_test_source.mdb", databaseFileName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }

        public override void ClearDatabase(IDbConnection connection) { throw new NotImplementedException(); }
        public override void DropDatabase()
        {
            string databaseFileName = TestDatabaseName + ".mdb";
            if (File.Exists(databaseFileName)) File.Delete(databaseFileName);
        }

    }
   

}